from application import app, db
from flask import Blueprint, request, make_response, redirect
from common.libs.Helper import ops_renderJSON, ops_renderErrJSON, ops_render
from common.libs.DataHelper import getCurrentTime
from common.models.mssqlmodel import MssqlTest
import pyodbc

import json, requests

it_page = Blueprint("it_page", __name__)


# @it_page.route('/getitdetail', methods=['GET', 'POST'])
# def getItDetail():
#     req = request.values
#     id = req['id'] if "id" in req else ""
#     a=Document.query.filter_by(id=id).first()
#     content=a.content
#     title=a.title
#     return json.dumps(
#         {"code": 200, "msg": "查询成功", "content": content,"title":title},
#         indent=4,
#         sort_keys=True,
#         default=str,
#         ensure_ascii=False)


@it_page.route('/showitmenu', methods=['GET', 'POST'])
def showITMenu():
    a = MssqlTest.query.all()
    rts = []
    for item in a:
        temp = dict(id=item.FPKID)
        rts.append(temp)

    for driver in pyodbc.drivers():
        print(driver)

    return json.dumps(rts, ensure_ascii=False)
